# Definition for singly-linked list.
class ListNode:
    def __init__(self, x):
        self.val = x
        self.next = None


class Solution:
    def removeElements(self, head: ListNode, val: int) -> ListNode:
        while head is not None and head.val == val:
            head = head.next
        if head is None:
            return None
        tmp = head
        while tmp.next:
            if tmp.next.val == val:
                tmp.next = tmp.next.next
                continue
            tmp = tmp.next
        return head



if __name__ == '__main__':
    so = Solution()
    s = 19
    r = so.isHappy(s)
    print(r)
